package com.situ.mall.controller.front;

import java.util.List;

import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.junit.validator.PublicClassValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.situ.mall.entity.Category;
import com.situ.mall.entity.Product;
import com.situ.mall.service.IProductService;

import freemarker.cache.StringTemplateLoader;

@Controller
@RequestMapping("/product")
public class FrontProductController {

	@Autowired
	private IProductService productService;

	// getProductListPage
	// 根据Id查询,然后跳转到照片墙
	@RequestMapping("/getProductListPage.shtml")
	public String getProductListPagae(Integer categoryId, Model model) {
		List<Product> list = productService.selectByCategoryId(categoryId);
		System.out.println(list);
		model.addAttribute("list", list);
		return "/product/list";
	}
	//跳转到商品详情页
		@RequestMapping("/detail.shtml")
		public String detail(Integer primarykey,Model model) {
			Product product = productService.selectByPrimaryKey(primarykey);
			model.addAttribute("product", product);
			
			return "/detail/detail";
		}
}
